/**
 * Created by Administrator on 2017/2/21.
 */
window.onload=function(){
    /* -----声明函数-----*/
   var num= 0,ys1= 0,ys2= 0,ys3= 0,nums= 0,numm=1;
    var nxl=1000,nfy=10,ngj=15;
    var numg=ngj,numf=nfy,numx=nxl;
    var nxl1=200,nfy1=5,ngj1=20,mn;
    var nxl2=400,nfy2=10,ngj2=25,nm;
    var nxl3=30000,nfy3=260,ngj3=300;
    var X_x = 7,X_y = 11;
    var floor=1;
    var arry1=[],arry2=[],arry3=[];
    var shy=document.getElementsByClassName("box3"),
        chy=document.getElementsByClassName("box2"),
        dsy=document.getElementsByClassName("box1"),
        dsy1=document.getElementsByClassName("box4"),
        an1=document.getElementById("an_1"),
        an2=document.getElementById("an_2"),
        an3=document.getElementById("an_3"),
        box6_2=document.getElementById("box6_2"),
        ann4=document.getElementsByClassName("ann_4"),
        x_1=document.getElementsByClassName("box01_xl1"),
        g_1=document.getElementsByClassName("box01_gj1"),
        f_1=document.getElementsByClassName("box01_fy1"),
        x_2=document.getElementsByClassName("box02_xl1"),
        g_2=document.getElementsByClassName("box02_gj1"),
        f_2=document.getElementsByClassName("box02_fy1"),
        imgs_1=document.getElementsByClassName("box01_1_1"),
        imgs_2=document.getElementsByClassName("box01_2_4"),
        box6_xl1=document.getElementsByClassName("box6_xl1"),
        box6_gj1=document.getElementsByClassName("box6_gj1"),
        box6_fy1=document.getElementsByClassName("box6_fy1"),
        box_b_xl1=document.getElementsByClassName("box_b_xl1"),
        box_b_gj1=document.getElementsByClassName("box_b_gj1"),
        box_b_fy1=document.getElementsByClassName("box_b_fy1"),
        box6_3_c=document.getElementsByClassName("box6_3_c"),
        but1=document.getElementById("but1");
/*0.路
* 1.墙
* 2.图鉴
* 3.勇士
* 4.怪物1
* 5.怪物2
* 6.血瓶红
* 7.血瓶蓝
* 8.攻击石
* 9.防御石
* 11.黄门
* 12.蓝门
* 13.红门
* 14.上楼梯
* 15.下楼梯
* 16.红钥匙
* 17.蓝钥匙
* 18.黄钥匙
* 19.盖伦大魔王
* */
    var ary=[
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
        [1,7,5,0,0,0,11,18,0,4,5,4,17,18,18,1,6,4,6,0,4,6,0,1],
        [1,1,1,11,1,1,1,0,1,1,1,1,1,1,0,1,0,0,0,1,1,1,17,1],
        [1,8,5,4,4,6,1,0,1,8,4,9,9,1,14,1,0,4,1,1,9,4,6,1],
        [1,8,5,0,6,5,1,17,1,6,4,7,1,1,1,1,1,12,1,8,4,6,16,1],
        [1,7,5,0,4,8,1,0,1,4,0,1,0,16,0,0,0,17,1,1,1,1,1,1],
        [1,1,1,1,1,1,1,0,1,11,1,0,1,0,1,1,1,17,1,9,8,4,7,1],
        [1,9,9,5,0,4,11,0,1,0,1,0,0,0,1,0,0,0,1,8,4,6,4,1],
        [1,1,1,1,11,1,1,0,1,4,9,1,1,12,1,0,1,0,1,1,6,7,8,1],
        [1,0,18,0,5,9,1,0,1,0,1,0,0,4,1,0,1,0,0,1,6,4,6,1],
        [1,4,0,17,18,4,1,0,1,6,0,4,0,6,1,0,1,0,0,1,1,12,1,1],
        [1,8,4,0,4,7,1,18,1,1,1,1,1,1,0,0,0,0,0,0,1,6,6,1],
        [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,12,1,1,0,1,8,4,1],
        [1,8,4,4,2,4,1,17,1,1,1,1,0,1,1,1,9,6,1,0,1,1,13,1],
        [1,4,0,0,5,6,1,0,1,7,6,1,0,1,7,8,4,9,1,0,0,0,0,1],
        [1,6,9,6,0,4,12,0,1,6,6,1,0,1,8,8,1,1,1,12,1,12,1,1],
        [1,5,0,0,0,5,1,0,1,6,9,1,0,1,1,12,1,7,8,4,1,4,8,1],
        [1,8,4,6,4,8,1,0,13,4,8,1,0,0,0,0,1,1,9,6,1,8,9,1],
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
        ];
    var ary1=[
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
        [1,8,6,1,0,0,0,1,0,0,5,18,16,1,9,5,12,0,0,17,17,1,0,1],
        [1,18,5,11,6,8,9,1,5,5,0,5,1,1,0,8,1,0,0,0,0,1,0,1],
        [1,9,6,1,0,4,0,1,17,1,0,0,6,1,14,1,1,0,0,0,5,12,0,1],
        [1,1,1,1,1,11,1,1,12,1,7,6,4,0,1,8,8,5,0,17,18,1,0,1],
        [1,17,18,6,1,0,6,1,5,6,1,1,1,11,1,1,1,1,1,1,1,1,0,1],
        [1,8,9,0,11,5,6,1,8,6,1,15,1,0,12,8,8,1,8,0,4,11,0,1],
        [1,4,8,0,1,0,8,1,9,8,1,0,1,0,1,1,1,1,1,6,6,1,0,1],
        [1,12,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,11,1,1,1,11,1],
        [1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,5,0,0,0,0,1],
        [1,1,11,1,1,1,1,1,1,1,12,1,1,6,9,8,16,1,0,18,18,18,0,1],
        [1,0,0,1,5,6,8,1,8,6,5,0,1,7,9,8,17,1,0,18,5,4,4,1],
        [1,0,1,0,5,6,8,1,9,6,5,0,13,6,9,8,18,1,0,0,5,8,9,1],
        [1,0,12,4,4,7,9,1,8,6,5,0,1,1,1,1,1,1,1,1,1,11,1,1],
        [1,17,1,1,1,1,1,1,1,1,1,12,1,0,4,5,6,1,6,0,4,5,4,1],
        [1,17,1,0,5,6,7,1,9,8,5,5,11,4,17,5,7,1,8,9,9,4,8,1],
        [1,0,1,0,5,6,7,1,9,8,5,2,1,0,4,5,8,1,0,5,8,6,6,1],
        [1,0,12,4,5,6,8,1,7,8,5,0,1,2,0,5,9,1,0,18,9,7,7,1],
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
    ];
    var ary2=[
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
        [1,7,5,0,0,0,11,18,13,4,5,4,17,18,18,1,6,4,6,0,4,6,0,1],
        [1,1,1,11,1,1,1,0,1,1,1,1,1,1,0,1,0,0,0,1,1,1,17,1],
        [1,8,5,4,4,6,1,0,1,8,4,9,9,1,19,1,0,4,1,1,9,4,6,1],
        [1,8,5,0,6,5,1,17,1,6,4,7,1,1,1,1,1,12,1,8,4,6,16,1],
        [1,7,5,0,4,8,1,0,1,4,0,1,0,16,0,0,0,17,1,1,1,1,1,1],
        [1,1,1,1,1,1,1,0,1,11,1,15,1,0,1,1,1,17,1,9,8,4,7,1],
        [1,9,9,5,0,4,11,0,1,0,1,0,0,0,1,0,0,0,1,8,4,6,4,1],
        [1,1,1,1,11,1,1,0,1,4,9,1,1,12,1,0,1,0,1,1,6,7,8,1],
        [1,0,18,0,5,9,1,0,1,0,1,0,0,4,1,0,1,0,0,1,6,4,6,1],
        [1,4,0,17,18,4,1,0,1,6,0,4,0,6,1,0,1,0,0,1,1,12,1,1],
        [1,8,4,0,4,7,1,18,1,1,1,1,1,1,0,0,0,0,0,0,1,6,6,1],
        [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,12,1,1,0,1,8,4,1],
        [1,8,4,4,2,4,1,17,1,1,1,1,0,1,1,1,9,6,1,0,1,1,13,1],
        [1,4,0,0,5,6,1,0,1,7,6,1,0,1,7,8,4,9,1,0,0,0,0,1],
        [1,6,9,6,0,4,12,0,1,6,6,1,0,1,8,8,1,1,1,12,1,12,1,1],
        [1,5,0,0,0,5,1,0,1,6,9,1,0,1,1,12,1,7,8,4,1,4,8,1],
        [1,8,4,6,4,8,1,0,13,4,8,1,0,0,0,0,1,1,9,6,1,8,9,1],
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
    ];

    /*--------拷贝数组-------*/

    var louceng1=ary.concat();

    /*-----------前景提要------------*/

        setInterval(function(){
            num++;
            /*---------第一页--------*/
            if(num==1){
                shy[0].style.display="block";
                chy[0].style.display="none";
                dsy1[0].style.display="none";
                dsy[0].style.display="none";
                var jd=document.getElementsByClassName("box3_1_d_1");
                var n=30;
                setInterval(function(){
                    n+=1;
                    if(n<=500){
                        jd[0].style.width=n+"px";
                    }
                },10);
        }
        /*----------第二页--------------*/
        if(num==2){
            chy[0].style.display="block";
            dsy1[0].style.display="none";
            dsy[0].style.display="none";
            shy[0].style.display="none";
        }
         /*----------第三页---------*/
        if(num==3){
            dsy1[0].style.display="block";
            dsy[0].style.display="none";
            shy[0].style.display="none";
            chy[0].style.display="none";
        }
         /*----------第四页----------*/
        if(num==4){
            dsy[0].style.display="block";
            chy[0].style.display="none";
            dsy1[0].style.display="none";
            shy[0].style.display="none";
        }
    },2000);
  /*------------移动事件------------*/
    an1.addEventListener('mouseover',function(){
        document.getElementsByClassName("box1_4")[0].style.background="radial-gradient(#8e8e8e,#000000)";
    });
    an1.addEventListener('mouseout',function(){
        document.getElementsByClassName("box1_4")[0].style.background="transparent";
    });
    an2.addEventListener('mouseover',function(){
        document.getElementsByClassName("box1_5")[0].style.background="radial-gradient(#8e8e8e,#000000)";
    });
    an2.addEventListener('mouseout',function(){
        document.getElementsByClassName("box1_5")[0].style.background="transparent";
    });
    an3.addEventListener('mouseover',function(){
        document.getElementsByClassName("box1_6")[0].style.background="radial-gradient(#8e8e8e,#000000)";
    });
    an3.addEventListener('mouseout',function(){
        document.getElementsByClassName("box1_6")[0].style.background="transparent";
    });
  /*----------点击事件---------------*/
    an2.addEventListener('click',function(){
        document.getElementsByClassName("box5")[0].style.display="block";
        document.getElementsByClassName("box1")[0].style.display="none";
    });
    ann4[0].addEventListener('click',function(){
        document.getElementsByClassName("box1")[0].style.display="block";
        document.getElementsByClassName("box5")[0].style.display="none";
    });
    an1.onclick=function() {
        document.getElementsByClassName("box1")[0].style.display = "none";
        document.getElementsByClassName("box6")[0].style.display = "block";
        mota(louceng1);
    };
    but1.onclick=function(){
        alert("该按钮不可使用")
    };
    /*----------函数区-------------*/


    function mota(louc1) {
        louc1[X_x][X_y]=3;

        /*-----移动及撞壁检测------------*/


        function game_1() {

            var eve = event.keyCode;
            if (eve == 38 && nums == 0) {
                if (X_x > 1) {
                    nums++;
                    yd(-1, 0);
                    n1("top");
                    numm=3;
                    mota(louceng1);
                    //n1("top");

                }
            }
            if (eve == 40 && nums == 0) {
                if (X_x < 18) {
                    nums++;
                    yd(1, 0);
                    n1("bottom");
                    numm=5;
                    mota(louceng1);
                    //n1("bottom");

                }
            }
            if (eve == 37 && nums == 0) {
                if (X_y > 1) {
                    nums++;
                    yd(0, -1);
                    n1("left");
                    numm=2;
                    mota(louceng1);
                    //n1("left");

                }
            }
            if (eve == 39 && nums == 0) {
                if (X_y < 22) {
                    nums++;
                    yd(0, 1);
                    n1("right");
                    numm=4;
                    mota(louceng1);
                    //n1("right");

                }
            }
        }

        /*----------执行函数----------*/

        document.body.onkeydown = game_1;
        if(numm==1){
            n1();
            numm--;
        }else if(numm==2){
            n1("left");
        }else if(numm==3){
            n1("top");
        }else if(numm==4){
            n1("right");
        }else if(numm==5){
            n1("bottom");
        }

        box6_xl1[0].innerText = numx;
        box6_gj1[0].innerText = numg;
        box6_fy1[0].innerText = numf;
        box_b_gj1[0].innerText = ys2;
        box_b_fy1[0].innerText = ys3;
        box_b_xl1[0].innerText = ys1;

        /*----------地图加载----------*/



        function n1(mm) {
            var a = "";
            for (var i = 0; i < louc1.length; i++) {
                for (var j = 0; j < louc1[i].length; j++) {
                    if (louc1[i][j] == 0) {
                        a = a + "<img class='box6_1' src='imgs/bg.png'>";
                    } else if (louc1[i][j] == 1) {
                        a = a + "<img class='box6_2' src='imgs/wall.png'>";
                    } else if (louc1[i][j] == 3) {
                        if (mm == "top") {
                            a = a + "<img class='box6_3' src='imgs/persont.png'>";
                        } else if (mm == "bottom") {
                            a = a + "<img class='box6_3' src='imgs/person1.png'>";
                        } else if (mm == "left") {
                            a = a + "<img class='box6_3' src='imgs/personl.png'>";
                        } else if (mm == "right") {
                            a = a + "<img class='box6_3' src='imgs/personr.png'>";
                        } else {
                            a = a + "<img class='box6_3' src='imgs/person1.png'>";
                        }
                    } else if (louc1[i][j] == 4) {
                        a = a + "<img class='box6_4' src='imgs/monster1.png'>";
                    } else if (louc1[i][j] == 5) {
                        a = a + "<img class='box6_4' src='imgs/monster2.png'>";
                    } else if (louc1[i][j] == 6) {
                        a = a + "<img class='box6_4' src='imgs/yjh.png'>";
                    } else if (louc1[i][j] == 7) {
                        a = a + "<img class='box6_4' src='imgs/yjl.png'>";
                    } else if (louc1[i][j] == 8) {
                        a = a + "<img class='box6_4' src='imgs/sth.png'>";
                    } else if (louc1[i][j] == 9) {
                        a = a + "<img class='box6_4' src='imgs/stl.png'>";
                    } else if (louc1[i][j] == 2) {
                        a = a + "<img class='box6_4' src='imgs/tj.png'>";
                    } else if (louc1[i][j] == 13) {
                        a = a + "<img class='box6_4' src='imgs/menh.png'>";
                    } else if (louc1[i][j] == 12) {
                        a = a + "<img class='box6_4' src='imgs/menl.png'>";
                    } else if (louc1[i][j] == 11) {
                        a = a + "<img class='box6_4' src='imgs/men.png'>";
                    } else if (louc1[i][j] == 14) {
                        a = a + "<img class='box6_4' src='imgs/lout.png'>";
                    } else if (louc1[i][j] == 15) {
                        a = a + "<img class='box6_4' src='imgs/xl.png'>";
                    } else if (louc1[i][j] == 16) {
                        a = a + "<img class='box6_4' src='imgs/ysh.png'>";
                    } else if (louc1[i][j] == 17) {
                        a = a + "<img class='box6_4' src='imgs/ysy.png'>";
                    } else if (louc1[i][j] == 18) {
                        a = a + "<img class='box6_4' src='imgs/yst.png'>";
                    }else if (louc1[i][j] == 19) {
                        a = a + "<img class='box6_4' src='imgs/monster4.png'>";
                    }
                }
            }
            box6_2.innerHTML = a;
        }

        imgs_1[0].innerHTML = "<img src='imgs/person1.png'>";

        /*-------移动核心函数------------*/
        function yd(a, b) {
            n1();
            if (louc1[X_x + a][X_y + b] == 0) {
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 1) {
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 4) {
                nxl1 = 200;
                dag(X_x + a, X_y + b);
                return;
            } else if (louc1[X_x + a][X_y + b] == 5) {
                nxl2 = 400;
                dag1(X_x + a, X_y + b);
                return;
            } else if (louc1[X_x + a][X_y + b] == 19) {
                nxl3 = 30000;
                dag2(X_x + a, X_y + b);
                return;
            }else if (louc1[X_x + a][X_y + b] == 16) {
                ys1 = ys1 + 1;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box_b_xl1[0].innerText = ys1;
                box6_3_c[0].innerText = "获得一把红钥匙";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 17) {
                ys2 = ys2 + 1;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box_b_gj1[0].innerText = ys2;
                box6_3_c[0].innerText = "获得一把蓝钥匙";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 18) {
                ys3 = ys3 + 1;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box_b_fy1[0].innerText = ys3;
                box6_3_c[0].innerText = "获得一把黄钥匙";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 11 && ys3 > 0) {
                ys3 = ys3 - 1;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box_b_fy1[0].innerText = ys3;
                box6_3_c[0].innerText = "打开一扇黄门";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 11 && ys3 == 0) {
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 12 && ys2 > 0) {
                ys2 = ys2 - 1;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box_b_gj1[0].innerText = ys2;
                box6_3_c[0].innerText = "打开一扇蓝门";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 12 && ys2 == 0) {
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 13 && ys1 > 0) {
                ys1 = ys1 - 1;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box_b_xl1[0].innerText = ys1;
                box6_3_c[0].innerText = "打开一扇红门";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 13 && ys1 == 0) {
                nums = 0;
                return;
            } else if (louc1[X_x + a][X_y + b] == 8) {
                numg += 3;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box6_3_c[0].innerText = "攻击加3";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                box6_gj1[0].innerText = numg;
                return;
            } else if (louc1[X_x + a][X_y + b] == 9) {
                numf += 3;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box6_3_c[0].innerText = "防御加3";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                box6_fy1[0].innerText = numf;
                return;
            } else if (louc1[X_x + a][X_y + b] == 6) {
                numx += 200;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box6_3_c[0].innerText = "血量加200";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                box6_xl1[0].innerText = numx;
                return;
            } else if (louc1[X_x + a][X_y + b] == 7) {
                numx += 400;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box6_3_c[0].innerText = "血量加400";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                box6_xl1[0].innerText = numx;
                return;
            } else if (louc1[X_x + a][X_y + b] == 2) {
                numf += 20;
                numg += 20;
                numx += 800;
                louc1[X_x][X_y] = 0;
                X_y = X_y + b;
                X_x = X_x + a;
                louc1[X_x][X_y] = 3;
                box6_3_c[0].innerText = "防御加20，攻击加20，血量加800";
                box6_3_c[0].style.display = "block";
                setTimeout(function () {
                    box6_3_c[0].style.display = "none";
                }, 1500);
                nums = 0;
                box6_fy1[0].innerText = numf;
                box6_gj1[0].innerText = numg;
                box6_xl1[0].innerText = numx;
                return;
            }

            /*-----------上下楼-----------*/
            /*---上楼------*/

            if (louc1[X_x + a][X_y + b] == 14 && floor == 1) {
                floor++;
                nums = 0;
                louc1[X_x][X_y] = 0;
                arry1 = louceng1.concat();
                louceng1 = ary1.concat();
                X_x=7;
                X_y=11;
                yd(0,0);
                louceng1[2][14] = 0;



            } else if (louc1[X_x + a][X_y + b] == 14 && floor == 2) {
                floor++;
                nums = 0;
                louc1[X_x][X_y] = 0;
                arry2 = louceng1.concat();
                louceng1 = ary2.concat();
                X_x=7;
                X_y=11;
                yd(0,0);
                louceng1[2][14] = 0;

            }
            /*-------下楼------*/
            if (louc1[X_x + a][X_y + b] == 15 && floor == 2) {

                floor--;
                nums = 0;
                louc1[X_x][X_y] = 0;
                arry2 = louceng1.concat();
                louceng1 = arry1.concat();
                X_x=2;
                X_y=14;
                yd(0,0);

                louceng1[7][11] = 0;

            } else if (louc1[X_x + a][X_y + b] == 15 && floor == 3) {

                floor--;
                nums = 0;
                louc1[X_x][X_y] = 0;
                arry3 = louceng1.concat();
                louceng1 = arry2.concat();
                X_x=2;
                X_y=14;
                yd(0,0);

                louceng1[7][11] = 0;
            }





        }

        /*-------------打怪函数----------------*/

        function dag(x, y) {
            nums++;
            imgs_2[0].innerHTML = "<img src='imgs/monster1.png'>";
            document.getElementsByClassName("box01")[0].style.display = "block";
            x_1[0].innerText = numx;
            x_2[0].innerText = nxl1;
            g_1[0].innerText = numg;
            g_2[0].innerText = ngj1;
            f_1[0].innerText = numf;
            f_2[0].innerText = nfy1;

            /*---------------血量动态计算-------------*/

            var set = setInterval(function () {
                if (ngj1 - numf < 0) {
                    mn = 0;
                } else {
                    mn = ngj1 - numf;
                }
                if (numg - nfy1 < 0) {
                    nm = 0;
                } else {
                    nm = numg - nfy1;
                }
                nxl = numx - mn;
                nxl1 = nxl1 - nm;
                x_1[0].innerText = nxl;
                x_2[0].innerText = nxl1;
                numx = nxl;
                if (nxl1 <= 0 && nxl > 0) {
                    document.getElementsByClassName("box01")[0].style.display = "none";
                    louc1[x][y] = 0;
                    clearInterval(set);
                    numx+=5;
                    box6_xl1[0].innerText = numx;
                    box6_3_c[0].innerText = "恭喜你消灭了一个骷髅剑士";
                    box6_3_c[0].style.display = "block";
                    setTimeout(function () {
                        box6_3_c[0].style.display = "none";
                    }, 1500);
                    nums = 0;
                    n1();
                } else if (nxl <= 0) {
                    alert("勇者都死了，还玩个毛啊！！！！");
                    clearInterval(set);
                    document.location.reload();
                    document.getElementsByClassName("box01")[0].style.display = "none";
                    document.getElementsByClassName("box6")[0].style.display = "none";

                    document.getElementsByClassName("box1")[0].style.display = "block";

                }
            }, 200);
        }

        function dag1(x, y) {
            imgs_2[0].innerHTML = "<img src='imgs/monster2.png'>";
            nums++;
            document.getElementsByClassName("box01")[0].style.display = "block";
            x_1[0].innerText = numx;
            x_2[0].innerText = nxl2;
            g_1[0].innerText = numg;
            g_2[0].innerText = ngj2;
            f_1[0].innerText = numf;
            f_2[0].innerText = nfy2;
            /*-----------血量动态计算-------------*/
            var set = setInterval(function () {
                if (ngj2 - numf < 0) {
                    mn = 0;
                } else {
                    mn = ngj2 - numf;
                }
                if (numg - nfy2 < 0) {
                    nm = 0;
                } else {
                    nm = numg - nfy2;
                }
                nxl = numx - mn;
                nxl2 = nxl2 - nm;
                x_1[0].innerText = nxl;
                x_2[0].innerText = nxl2;
                numx = nxl;
                if (nxl2 <= 0 && nxl > 0) {
                    document.getElementsByClassName("box01")[0].style.display = "none";
                    louc1[x][y] = 0;
                    nums = 0;
                    clearInterval(set);
                    box6_3_c[0].innerText = "恭喜你消灭了一个羊头恶魔";
                    numf+=1;
                    box6_3_c[0].style.display = "block";
                    setTimeout(function () {
                        box6_3_c[0].style.display = "none";
                    }, 1500);
                    box6_xl1[0].innerText = numx;
                    n1();
                } else if (nxl <= 0) {
                    alert("勇者都死了，还玩个毛啊！！！！");
                    clearInterval(set);
                    document.location.reload();
                    document.getElementsByClassName("box01")[0].style.display = "none";
                    document.getElementsByClassName("box6")[0].style.display = "none";
                    document.getElementsByClassName("box1")[0].style.display = "block";


                }
            }, 200);
        }
        function dag2(x, y) {
            imgs_2[0].innerHTML = "<img src='imgs/monster4.png'>";
            nums++;
            document.getElementsByClassName("box01")[0].style.display = "block";
            x_1[0].innerText = numx;
            x_2[0].innerText = nxl3;
            g_1[0].innerText = numg;
            g_2[0].innerText = ngj3;
            f_1[0].innerText = numf;
            f_2[0].innerText = nfy3;
            /*-----------血量动态计算-------------*/
            var set = setInterval(function () {
                if (ngj3 - numf < 0) {
                    mn = 0;
                } else {
                    mn = ngj3 - numf;
                }
                if (numg - nfy3 < 0) {
                    nm = 0;
                } else {
                    nm = numg - nfy3;
                }
                nxl = numx - mn;
                nxl3 = nxl3 - nm;
                x_1[0].innerText = nxl;
                x_2[0].innerText = nxl3;
                numx = nxl;
                if (nxl3 <= 0 && nxl > 0) {
                    document.getElementsByClassName("box01")[0].style.display = "none";
                    louc1[x][y] = 0;
                    nums = 0;
                    clearInterval(set);
                    box6_3_c[0].innerText = "你们这群窥视本魔王宝藏的家伙，给我等着！！！";
                    box6_3_c[0].style.display = "block";
                    setTimeout(function () {

                        box6_3_c[0].style.display = "none";
                        alert("你赢了");
                        document.location.reload();
                        document.getElementsByClassName("box01")[0].style.display = "none";
                        document.getElementsByClassName("box6")[0].style.display = "none";
                        //document.getElementsByClassName("box1")[0].style.display = "block";

                    }, 4000);
                    box6_xl1[0].innerText = numx;
                    n1();
                } else if (nxl <= 0) {
                    alert("勇者都死了，还玩个毛啊！！！！");

                    clearInterval(set);
                    document.location.reload();
                    document.getElementsByClassName("box01")[0].style.display = "none";
                    document.getElementsByClassName("box6")[0].style.display = "none";


                    document.getElementsByClassName("box1")[0].style.display = "block";

                }
            }, 200);
        }
        /* if (louc1[X_x + a][X_y + b] == 5) {
         x1[0].innerText = numxl;
         x2[0].innerText = numxl2;
         numxl = numxl + numfgy - numgongj2;
         numxl2 = numxl2 + numfgy2 - numgongj;
         x1[0].innerText = numxl;
         x2[0].innerText = numxl2;
         if (numxl2 == 0) {
         document.getElementsByClassName("box01")[0].style.display = "none";
         louc1[x][y] = 0;
         console.log("打怪的之后" + louc1[x][y]);
         n1();
         clearInterval(set);
         } else {
         alert("勇者都死了，还玩个毛啊！！！！");
         clearInterval(set);
         }
         }*/
    }
}